package ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.evento;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;

import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.apliccion.AproximandoAlEvento;
import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.apliccion.EventoDatProvider;
import clasesPrincipales.MyDate;

public class BuscarEventoPage extends Panel{
	private static final long serialVersionUID = -5056702394377028032L;
	private EventoDatProvider provider = new  EventoDatProvider();


	
	
	public BuscarEventoPage(String id) {
	
	super(id,  new CompoundPropertyModel<AproximandoAlEvento>(new AproximandoAlEvento()));
	Form<AproximandoAlEvento> form = new Form<AproximandoAlEvento>("eventoBusquedaForm");
	

	form.add(new Label("lbl_ev","EVENTOS:"));
	form.add(new Label("lbl_fecha","Fecha aproximada"));
	form.add(new TextField<MyDate> ("tiempo"));
    form.add(new Label("lbl_descr","Descripcion"));
    form.add(new TextField<String>("descripcion"));
    form.add(new Label("lbl_importante","Es importante"));
    form.add(new CheckBox("importante"));
  
    
    
    //GRILLA
    final GuardaGrillaEventoPanel grilla = new GuardaGrillaEventoPanel("guardaGrillaEvento", provider);
    grilla.setOutputMarkupId(true);
    this.add(grilla);
    
      
    //BOTON
    form.add(new AjaxSubmitLink("botonBuscarEvento") { 
		private static final long serialVersionUID = 1L;
		@Override
		protected void onSubmit(AjaxRequestTarget arg0, Form<?> form) {
			BuscarEventoPage.this.provider.buscar((AproximandoAlEvento)BuscarEventoPage.this.getDefaultModel().getObject());
			arg0.addComponent(grilla);
		}
		
		@Override
		protected void onError(AjaxRequestTarget arg0, Form<?> arg1) {
			// TODO Auto-generated method stub
			
		}
		
		
		
	});
    
    this.add(form);
    
    
 

}}
